package com.hub.nio.socket.bio;


import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @ author 令狐冲
 * @ date & time 2025/1/23 16:28
 */
public class BIOServer {

    public static void main(String[] args) throws IOException {
        try {
            ServerSocket serverSocket = new ServerSocket(9999);
            System.out.println("服务端已经启动！");
            ExecutorService executor = Executors.newFixedThreadPool(10);
            boolean flag = true;
            while (flag) {
                Socket accept = serverSocket.accept();
                executor.execute(new BIOHandler(accept));
            }
            executor.shutdown();
            serverSocket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
